﻿<controls:PivotItem x:Class="DCView.ViewArticleListPivotItem"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"                    
    xmlns:my="clr-namespace:DCView"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480">

    <controls:PivotItem.Resources>
        <my:BoolToColorConverter x:Key="BoolToColorConverter" />
    </controls:PivotItem.Resources>
  

    <Grid Margin="-5, 0">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <StackPanel x:Name="SearchPanel" Grid.Row="0" Visibility="Collapsed">
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                <RadioButton GroupName="SearchType" x:Name="SearchTypeSubject" Content="제목" IsChecked="True" Click="SearchType_Click"/>
                <RadioButton GroupName="SearchType" x:Name="SearchTypeContent" Content="내용" Click="SearchType_Click"/>
                <RadioButton GroupName="SearchType" x:Name="SearchTypeName" Content="이름" Click="SearchType_Click"/>                
            </StackPanel>
            
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto"/>                    
                </Grid.ColumnDefinitions>
                <TextBox Grid.Column="0" x:Name="SearchTextBox" />
                <Button Grid.Column="1" Content="검색" Click="SearchButton_Click"/>
            </Grid>
        </StackPanel>
        

        <ListBox x:Name="ArticleList" Grid.Row="1"
                 ManipulationCompleted="ArticleList_ManipulationCompleted">
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />                    
                </Style>
            </ListBox.ItemContainerStyle>
            

            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="12, 12" Tap="ArticleListItem_Tap" Tag="{Binding Article}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Rectangle Grid.Column="0" Width="5" HorizontalAlignment="Stretch" Fill="{Binding HasImageBrush}" />
                        <StackPanel Grid.Column="1" Margin="0, 0, 0, 3">
                            <TextBlock Text="{Binding Title}" 
                                       Style="{StaticResource DCViewTextMediumStyle}"
                                       TextWrapping="Wrap" />

                            <my:ArticleStatusView />

                        </StackPanel>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        <toolkit:PerformanceProgressBar Grid.Row="2" x:Name="LoadingArticleListProgressBar" Background="Transparent"/>

    </Grid>
</controls:PivotItem>